<?php
/**
 * Created by PhpStorm.
 * User: 17274
 * Date: 2018/3/29
 * Time: 12:43
 */

namespace app\admin\controller;

use think\Controller;
use think\Config;

class Base extends Controller
{

    /*
     * 初始化
     * */
    public function _initialize(){
        //启用原生session
        session_start();
    }

    /*
       * 权限配置
       * child中 如若为0 代表不存在改权限模组
       * */
    public static function getAuthorityList($role_id){
        $authorityArr=[];

        $system = array(
            "controller"=>"System",
            "controllerName"=>"核心熔炉",
            "child"=>array(
                array(
                    "name"=>"议员管理",
                    "add"=>"admin_add",
                    "delete"=>"admin_del",
                    "select"=>"admin_index",
                    "update"=>"admin_edit"
                ),
                array(
                    "name"=>"保密等级",
                    "add"=>"role_add",
                    "delete"=>"role_del",
                    "select"=>"role_index",
                    "update"=>"role_edit",
                    "authority"=>"role_authority"
                )
            )
        );

        $logs = array(
            "controller"=>"Logs",
            "controllerName"=>"核心熔炉",
            "child"=>array(
                array(
                    "name"=>"记录中心",
                    "select"=>"logs_index"
                )
            )
        );

        $server = array(
            "controller"=>"Server",
            "controllerName"=>"服务监控",
            "child"=>array(
                array(
                    "name"=>"实时监控",
                    "select"=>"server_index"
                )
            )
        );

        if ($role_id==Config::get('superRoleId')){
            array_push($authorityArr,$system);
        }
        array_push($authorityArr,$logs);
        array_push($authorityArr,$server);

        return $authorityArr;
    }

}